/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.jautomation.pdetect.scantypes;

import java.awt.Point;
import org.jautomation.pdetect.IPixDetect;
import org.jautomation.pdetect.ScanReceiver;
import org.jautomation.pdetect.WorkerContext;

/**
 *
 * @author Dominik Hensler
 */
public class PixelMonitor implements IPixDetect {
    ScanReceiver _scanReceiver;
    
    public PixelMonitor(ScanReceiver scanReceiver){
        this._scanReceiver=scanReceiver;        
    }

    @Override
    public void execute(WorkerContext pcontext) {
        if (pcontext.getCommandArray().length > 2 || 
                       ((pcontext.getCoordP().x!=0)
                     &&(pcontext.getCoordP().y!=0))) {
            //performance?
            try {
                pcontext.setCoordP(new Point(Integer.parseInt(pcontext.getCommandArray()[1]),
                        Integer.parseInt(pcontext.getCommandArray()[2])));
            } catch (NumberFormatException nfe) {                
            }
        this._scanReceiver.getScreenShot();
        this._scanReceiver.comparePixel(pcontext);
        }
    }
}
